package com.juyu.miliao.authentication.dao.mysql;

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.juyu.miliao.common.dataSource.tool.operate.Operate;

import java.util.HashMap;
import java.util.Map;

@Repository
public class UserWalletDao {
	@Autowired
	private SqlSession sqlSession;

	@Operate("strategy('byUserId', #userId)")
	public int addUserWallet(long userId){
		return sqlSession.insert("addUserWallet", userId);
	}

	@Operate("strategy('byUserId', #userId)")
	public int reviseDeposit(long userId,int deposit){
		Map<String,Object> map = new HashMap<>();
		map.put("userId",userId);
		map.put("deposit",deposit);
		return sqlSession.update("reviseDeposit", map);
	}

	@Operate("strategy('byUserId', #userId)")
    public int addUserWalletBeans(Long userId, int sendBeans) {
		Map<String,Object> map = new HashMap<>();
		map.put("userId",userId);
		map.put("beans",sendBeans);
		return  sqlSession.update("addUserWalletBeans", map);
    }
}
